<template>
	<view class="bg_color list_home">
		<Screen :screenData="screenData" :search="search" @changeScreenData="changeScreenData"></Screen>
		<template v-if="listData.length">
			<Scroll :isTriggered="isTriggered" :isXiaLa="total > listData.length" @refresherrefresh="refresherrefresh" @scrolltolower="scrolltolower">
				<Add title="新增意见建议" @add="add"></Add>
				<view class="pdd32 content">
					<ListITem
						v-for="(item, index) in listData"
						:field="field"
						:stateData="stateData"
						v-bind="item"
						@operate="() => operate(item)"
						@clickItem="() => clickItem(item.id)"
					></ListITem>
				</view>
			</Scroll>
		</template>
		<NoData v-else :show="!listData.length && (screenData.status != 0 || screenData.keywords != '')">
			<view class="font28">还没有新增过意见建议!</view>
			<view class="no_btn font28" @click="add">新增意见建议</view>
		</NoData>
		<DeleteState v-if="isDelete" :success="success" @successReturn="fanhui" @failReturn="fanhui"></DeleteState>
	</view>
	<Operate :show="show" @editItem="editItem" @deleteItem="deleteItem" @close="show = false"></Operate>
	<DeleteModal :deleteShow="deleteShow" @confirm="confirm" @close="deleteShow = false"></DeleteModal>
</template>
<script>
const field = {
	title: 'optionTitle',
	address: 'optionPlace',
	time: 'optionTime',
	content: 'optionContent',
	type: 'providerName',
	state: 'status',
	id: 'id',
	avatar: 'avatar'
};
const stateData = {
	1: {
		name: '未处理',
		className: 'red'
	},
	2: {
		name: '已处理',
		className: 'green'
	},
	3: {
		name: '三本账',
		className: 'yellow'
	}
};
const search = {
	type: 'status',
	text: 'keywords',
	searchList: [
		{ name: '全部', value: '0' },
		{ name: '未处理', value: '1' },
		{ name: '已处理', value: '2' },
		{ name: '三本账', value: '3' }
	]
};
</script>
<script setup>
import Screen from 'com/Screen.vue';
import ListITem from 'com/ListITem.vue';
import DeleteModal from 'com/modal/DeleteModal.vue';
import DeleteState from 'com/modal/DeleteState.vue';
import NoData from 'com/modal/NoData.vue';
import Operate from 'com/Operate.vue';
import Add from 'com/Add.vue';
import Scroll from 'com/Scroll.vue';
import { useGetData } from 'hooks';
const {
	total,
	success,
	confirm,
	fanhui,
	editItem,
	isDelete,
	setTotal,
	screenData,
	scrolltolower,
	refresherrefresh,
	add,
	isTriggered,
	listData,
	changeScreenData,
	clickItem,
	operateItem,
	setOperateItem,
	operate,
	show,
	deleteItem,
	deleteShow
} = useGetData('opinionAdded', 'suggestions');
</script>

<style lang="scss" scoped></style>
